.ecc-silk-mapping {
    margin: 1rem;

    .mdl-dialog {
        width: 40rem;
    }

    .Select-menu-outer {
        z-index: 3;
    }

    .Select-option {
        @include typo-body-1();
    }

    .Select-option__label,
    .Select-option__value,
    .Select-option__description {
        display: block;
        white-space: nowrap;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        line-height: 1.25;
    }

    .Select-option__label {
        font-weight: 500;
    }

    .Select-option__value {
        font-size: 0.8em;
    }

    .Select-option__description {
        font-size: 0.9em;
    }

    .mdl-alert--narrowed {
        .mdl-alert__content > *:not(:first-child) {
            display: hidden;
        }

        .mdl-alert__content,
        .mdl-alert__content > * {
            max-height: 5em;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
    }
}

.ecc-silk-mapping__header {
    justify-content: flex-end;
}


.ecc-silk-mapping__content {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    padding: 0 1rem 1rem 1rem;
}

.ecc-silk-mapping__treenav {
    flex-basis: 25%;
    min-width: 10em;
    min-height: 10em;
    max-width: 100%;
    flex-shrink: 1;
    flex-grow: 1;
    position: relative;

    ul, li {
        list-style-type: none;
    }

    ul {
        margin: 0;
        padding: 0;

        &.ecc-silk-mapping__treenav--subtree {
            padding-left: 2rem;
        }
    }

    .ecc-silk-mapping__treenav--maintree {
        position: sticky;
        left: 0;
        top: 0;
        width: 100%;
        max-height: calc(100vh - 150px);
        overflow: auto;
        padding-bottom: 1rem;
        box-sizing: border-box;

        & > li {
            //min-width: 20em;
        }
    }

    .ecc-silk-mapping__treenav--item {
        display: flex;
        justify-content: flex-start;
        align-items: center;
        color: $button-secondary-color;
    }

    .ecc-silk-mapping__treenav--item-active {
        font-weight: 500;
        background-color: $button-active-color;
    }

    .ecc-silk-mapping__treenav--item-toggler {
        flex-grow: 0;
        flex-shrink: 0;
        font-size: 1.5rem;
        line-height: 2rem;
        width: 2rem;
        min-width: 2rem;
        height: 2rem;

        .material-icons {
            transform: translate(-1rem, -1rem);
            line-height: 2rem;
            width: 2rem;
        }

        &.material-icons {
            font-size: 1rem;
            text-align: center;
            color: to_color($palette-grey-500);
        }
    }

    .ecc-silk-mapping__treenav--item-handler {
        flex-grow: 1;
        flex-shrink: 1;
        padding: 0.25rem 0.5rem;
        @include typo-body-1();
        cursor: pointer;
        border: none;
        text-align: left;
        background-color: transparent;
        outline: none;

        &:hover, &:focus {
            background-color: $button-hover-color;
        }
    }

    .ecc-silk-mapping__treenav--item-maintitle,
    .ecc-silk-mapping__treenav--item-subtitle {
        display: block;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .ecc-silk-mapping__treenav--item-subtitle {
        @include typo-caption();
    }
}

.ecc-silk-mapping__rules {
  flex-basis: 75%;
  flex-grow: 1;
  flex-shrink: 1;
  min-width: 50%;
}

.ecc-silk-mapping__ruleshead {
    position: relative;
    margin-bottom: 1rem;

    .mdl-card__title {
        align-items: flex-start;
        position: sticky;
        top: 0;
        z-index: 10;
        background-color: $card-background-color;
    }

    .mdl-card__title-back {
        position: relative;
        left: -0.5rem;
        top: -0.25rem;
    }

    .mdl-card__title-text {
        flex-grow: 1;
        align-self: center;
        display: flex;
        flex-direction: column;
        @include typo-subhead();

        .mdl-card__title-text-sup {
            @include typo-caption();

            .mdl-chip {
                height: auto;
                line-height: 2;
                font-size: 1em;
            }

            .mdl-chip__text {
                font-size: 1em;
            }
        }

        .mdl-card__title-text-main {
            font-weight: 500;
            //font-size: 1.25rem;
        }

        .mdl-card__title-text-sub {
            //font-size: 1.25rem;
        }
    }

    .mdl-card__content {
        max-height: calc(99vh - 36px - 2*8px - 2*16px - 3*16px - 150px;);
        overflow: overlay;
        margin: 0;
        padding: 0 1rem;
    }

    .mdl-card__actions {
        border-bottom: 1px solid $card-border-color;
    }
}

.ecc-silk-mapping__ruleslist {

    .mdl-card__title-text {
        flex-grow: 1;
    }

    .mdl-list {
        margin: 0;
        padding: 0;
    }

    .mdl-list__item {
        border-bottom: $data-table-dividers;

        &:last-child {
            border-bottom: none;
        }

    }

    .ecc-silk-mapping__ruleitem--literal {
        .mdl-list__item-secondary-content {
            align-self: flex-start;
        }
    }

    .ecc-silk-mapping__ruleitem--object {
        .mdl-list__item-secondary-content {
            align-self: center;
        }
    }

    .ecc-silk-mapping__ruleitem {
        overflow: visible;
        @include material-animation-default(0.28s);
        transition-property: background-color;

        &:hover {
            background-color: $data-table-hover-color;
        }
    }

    .ecc-silk-mapping__ruleitem--expanded {
        padding-left: 0;
        border-left: $data-table-dividers;
        border-right: $data-table-dividers;

        &:hover {
            background-color: transparent;
        }
    }

    .ecc-silk-mapping__ruleitem--defect {
        color: to_color($palette-orange-800);
        background-color: to_color($palette-orange-50);
        border-color: to_color($palette-orange-100);
    }

    .mdl-list__item-primary-content {
        display: block;
    }
    .mdl-list__item-primary-content {
        width: 50vw;
    }

    .ecc-silk-mapping__ruleitem-icon {
        font-size: 1.25em;
        vertical-align: text-bottom;
        margin-right: 0.1em;
    }

    .ecc-silk-mapping__ruleitem-content {
        @include typo-body-1();
        max-width: 100%;
    }

    .ecc-silk-mapping__ruleitem-headline {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        font-weight: 500;
    }

    .ecc-silk-mapping__ruleitem-subline {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        @include typo-caption();
    }


    .ecc-silk-mapping__suggestitem-checkbox {
        align-self: center;
        flex-grow: 0;
        flex-shrink: 0;
        width: 0;
    }

    .ecc-silk-mapping__ruleitem--summary {

        @media (min-width: $grid-desktop-breakpoint) {
            .ecc-silk-mapping__ruleitem-content {
                display: flex;
                flex-direction: row;
                flex-wrap: nowrap;
                justify-content: space-between;
                align-items: baseline;
            }

            .ecc-silk-mapping__ruleitem-headline,
            .ecc-silk-mapping__ruleitem-subline {
                font-size: $data-table-font-size;
                flex-grow: 1;
                box-sizing: border-box;
                padding: 0.25em;
                max-width: 33%;
            }
            .ecc-silk-mapping__sug-ruleitem-headline,
            .ecc-silk-mapping__sug-ruleitem-subline,
            .ecc-silk-mapping__sug-ruleitem-lastline {
                font-size: $data-table-font-size;
                flex-grow: 1;
                box-sizing: border-box;
                padding: 0.25em;
                width: 31%;
            }
            .ecc-silk-mapping__sug-ruleitem-lastline {
                width: 7%;
            }
            .hide-in-table {
                display: none;
            }

            .ecc-silk-mapping__ruleitem-reorderhandler {
                .material-icons {
                    transform: translate(-1px, 10%);
                }
            }

            .ecc-silk-mapping__suggestitem-headline {
                width: 66%;
                max-width: 66%;
            }

            .ecc-silk-mapping__suggestitem-subline {
                width: 33%;
                max-width: 33%;
            }
        }
    }

    .ecc-silk-mapping__ruleitem-reorderhandler {
        width: 1rem;
        position: relative;
        left: -0.5rem;
        border: $data-table-dividers;
        align-self: stretch;
        background-color: to_color($color-white);

        .contextmenu-container {
            position: absolute;
            left: 1px;
            top: 1px;
            right: 1px;
            bottom: 1px;
        }

        .mdl-button--icon,
        .material-icons {
            overflow: hidden;
            position: absolute;
            left: 0;
            top: 0;
            height: 100%;
            width: 100%;
            border-radius: 0;
            min-width: 0;
            line-height: 100%;
            opacity: 0.61;

            &:hover, &:focus, &:active {
                opacity: 1;
            }
        }

        .material-icons {
            transform: translate(-1px, 25%);
        }
    }

    .mdl-card__actions--fixed {
        position: sticky;
        bottom: 0;
    }

    & > .mdl-card > .mdl-card__actions {
        background-color: rgba(to_color($card-background-color), 0.90);
        z-index: 1;
    }

}

.ecc-silk-mapping__ruleslist-floatingactions {
    position: absolute;
    bottom: 3rem;
    right: calc(2rem + 32px);

    .mdl-button--fab {
        // TODO: large fab is broken, need to be fixed in gui elements
        width: 56px;
        height: 56px;
    }

}

.ecc-silk-mapping__ruleslist-floatingactions--trigger {
    position: absolute;
    bottom: 0;
    right: 0;
    z-index: 1;
    transition: opacity .2s, width .2s, height .2s, border-radius .2s;

    &.is-active {
        opacity: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
    }
}

.ecc-silk-mapping__ruleslist-floatingactions--list {
    position: relative;
    bottom: 3px;
    right: 3px;
    top: auto;
    left: auto;
    height: auto;
    overflow: hidden;
    width: 50px;
    min-width: 0;
    max-height: 50px;
    padding: 0;
    opacity: 0;
    border-radius: 50%;
    z-index: 0;
    transition: opacity .2s, width .2s, max-height .2s, border-radius .2s;

    .mdl-menu__item {
        opacity: 1;
    }

    .material-icons {
        vertical-align: middle;
        margin-right: 0.5em
    }

    .ecc-silk-mapping__ruleslist-floatingactions--trigger.is-active + & {
        bottom: 0;
        right: 0;
        width: 20em;
        max-height: 20em;
        background-color: white;
        opacity: 1;
        border-radius: 0;
        z-index: 2;
    }
}

.ecc-silk-mapping__ruleslist-floatingactions--list-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: transparent;
}

.ecc-silk-mapping__rulesviewer,
.ecc-silk-mapping__ruleseditor {

    .ecc-silk-mapping__ruleslist & {
        margin: -1rem 0;
    }

    .mdl-card__content {
        @include typo-body-1();
        margin: 0;
        padding: 0 1rem;
    }
}

.ecc-silk-mapping__rulesviewer__title {

    .mdl-card__title-text {
        @include typo-subhead();
    }
}

.ecc-silk-mapping__rulesviewer__attribute {

    margin: 0.5rem 0 1rem 0;
    @include typo-body-1();

    dt, dd {
        margin: 0 0 0.25rem 0;
        padding: 0;
    }

    code {
        font-size: 0.9em;
    }

    .ecc-silk-mapping__rulesviewer__attribute-label {
        font-size: $input-text-floating-label-fontsize;
        //font-weight: 300;
        //display: list-item;
        list-style-type: square;
        list-style-position: inside;
    }

    .ecc-silk-mapping__rulesviewer__attribute-title {
        // font-weight: 500;
    }

    .ecc-silk-mapping__rulesviewer__attribute-info {
        max-width: 100%;
        overflow: auto;
        font-weight: 300;

        p {
            font-weight: 300;
            margin-bottom: 0;
        }
    }

}

.ecc-silk-mapping__rulesviewer__infobox {

    display: flex;

    &.is-narrowed {

        .ecc-silk-mapping__rulesviewer__infobox-main,
        .ecc-silk-mapping__rulesviewer__infobox-sub {

            max-height: 1.39em;
            overflow: hidden;

            * {
                display: inline;
            }

            & > * {
                display: inline-block;
                overflow: hidden;
                text-overflow: ellipsis;

                &:not(:first-child) {
                    display: none;
                }
            }
        }

        @media (min-width: $grid-desktop-breakpoint) {
            .ecc-silk-mapping__rulesviewer__infobox-content {
                display: flex;
                // align-items: baseline;
                flex-wrap: nowrap;

                & > div + div {
                    padding-left: 1rem;
                    box-sizing: border-box;
                    position: relative;

                    &:before {
                        content: '•';
                        font-size: 1rem;
                        width: 1rem;
                        height: 1.39em;
                        position: absolute;
                        top: 0;
                        left: 0;
                        text-align: center;
                        vertical-align: middle;
                        /*
                        */
                    }
                }

            }

            .ecc-silk-mapping__rulesviewer__infobox-main {
                flex-grow: 0;
                flex-shrink: 0;
                max-width: 61%;
            }

            .ecc-silk-mapping__rulesviewer__infobox-sub {
                flex-grow: 1;
                flex-shrink: 1;
            }
        }
    }
}

.ecc-silk-mapping__rulesviewer__infobox-toggler {
    flex-grow: 0;
    flex-shrink: 0;
    margin: -0.5rem 0 0 -1rem;
}

.ecc-silk-mapping__rulesviewer__infobox-content {

    flex-grow: 1;
    flex-shrink: 1;
    line-height: 1.39;
    width: 50vw; // this is a spooky hack but it prevents that the layout explodes

    p {
        line-height: 1.39;
        font-size: 1em;
    }

    .ecc-silk-mapping__rulesviewer__infobox-sub {
        font-size: 0.95em;
    }
}

.ecc-silk-mapping__rulesviewer__examples-table {

    border: 0;
    width: 100%;

    th, td {
        text-align: left;
        padding: 0.5em 1em;
        white-space: normal;
        height: auto;
        border-bottom-color: #ddd;

        &:first-of-type,
        &:last-of-type {
            padding: 0.5em 1em;
        }

        &.ecc-silk-mapping__rulesviewer__examples-table__path {
            max-width: 33%;
        }
        &.ecc-silk-mapping__rulesviewer__examples-table__value {
            max-width: 33%;
        }
        &.ecc-silk-mapping__rulesviewer__examples-table__result {
            max-width: 33%;
        }
    }

    tr:first-of-type td.ecc-silk-mapping__rulesviewer__examples-table__result,
    tr:last-of-type td {
        border-bottom-color: #bbb;
    }

    thead {
        border: 0;
    }

    tbody {
        tr {
            &:hover {
                background-color: transparent;
            }
        }
    }

}

.clickable {
    cursor: pointer;
}
